Skip to content

fix(agent_toolset): grep tolerates extra model-supplied args#1719

Open
nadavshohat wants to merge 1 commit into
anthropics:mainfrom
nadavshohat:fix/grep-tolerate-extra-args
Open

fix(agent_toolset): grep tolerates extra model-supplied args#1719
nadavshohat wants to merge 1 commit into
anthropics:mainfrom
nadavshohat:fix/grep-tolerate-extra-args

Conversation

@nadavshohat

Copy link
Copy Markdown

What

beta_grep_tool's grep(pattern, path) is registered with the full agent_toolset_20260401 grep schema, but its signature accepts only pattern/path. When a model calls grep with any other argument, @beta_async_tool's validate_call rejects the whole call:

ValidationError: 2 validation errors for beta_grep_tool.<locals>.grep
head_limit    Unexpected keyword argument
output_mode   Unexpected keyword argument
ValueError: Invalid arguments for function grep

This is not hypothetical: it happens in a real self-hosted EnvironmentWorker session. The model routinely emits Claude-Code-style grep options (output_mode, head_limit, -i, context lines) that are not in the GrepInput schema (which is pattern/path only). Every such call fails and the model gets a hard error instead of search results, so grep is effectively unusable for those calls and the agent falls back to bash.

Fix

Accept and ignore unknown keyword arguments in the reference grep implementation (**_ignored). The tool still searches by pattern/path; extra options are tolerated rather than fatal. Minimal, matches the schema's documented contract, and unblocks real agent runs.

Notes

  • Only grep is changed; the other toolset functions weren't observed failing.
  • Honoring output_mode/head_limit for real could be a follow-up, but that would also need the GrepInput schema (Stainless-generated) to declare them.

@nadavshohat nadavshohat requested a review from a team as a code owner June 30, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant